package com.expense.servlet.expensesInfo;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.expense.entity.ExpensesDetailsInfo;
import com.expense.entity.ExpensesInfo;
import com.expense.entity.TeamInfo;
import com.expense.entity.UserInfo;
import com.expense.services.BasicServices;
import com.expense.services.UserInfoServices;
import com.expense.services.expensesInfo.ExpensesInfoServices;
import com.expense.servlet.BasicServlet;
import com.expense.util.Constants;
import com.expense.util.PaginatedList;

/**
 * 费用信息 Servlet
 * @author xj
 * */
public class ExpensesInfoServlet extends BasicServlet {
	private ExpensesInfoServices services=new ExpensesInfoServices();
	/**
	 * Constructor of the object.
	 */
	public ExpensesInfoServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html");
		String opt=request.getParameter("opt");
		if(opt.equals("searchExpensesInfoList")){//查询费用信息列表
			services.searchExpensesInfoList(request, response);
		}else if(opt.equals("toAddTeamData")){//到新增团体费用
			services.toAddTeamData(request, response);
		}else if(opt.equals("addTeamData")){//新增团体费用
			services.addTeamData(request, response); 
		}else if(opt.equals("toAddIndividualData")){//到新增个人费用
			services.toAddIndividualData(request, response);
		}else if(opt.equals("addIndividualData")){//新增个人费用
			services.addIndividualData(request, response);
		}else if(opt.equals("deleteSingleData")){//删除一笔费用
			services.deleteSingleData(request, response);
		}else if(opt.equals("toUpdateSingleData")){//到修改一笔费用
			services.toUpdateSingleData(request, response);
		}else if(opt.equals("editIndividualData")){//修改一笔费用
			services.editIndividualData(request, response);
		}else if(opt.equals("editTeamData")){//修改一笔团体费用
			services.editTeamData(request, response);
		}else if(opt.equals("expensesInfoListIndexView")){//首页显示费用信息
			services.expensesInfoListIndexView(request, response);
		}
		
		
		
		
		
		
	}
	
	
	

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
